<div class="row-content am-cf">
	<div class="row">
		<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
			<div class="widget am-cf">
				<form id="my-form" class="am-form tpl-form-line-form" method="post">
					<div class="widget-body">
						<fieldset>
							<div class="widget-head am-cf">
								<div class="widget-title am-fl">微信支付设置</div>
							</div>
							{if $user['applet']['status']['value'] == 1}
							<input type="hidden" name="data[app_id]" value="{$user['applet']['app_id']}">
							<input type="hidden" name="data[is_sub]" value="{$model['is_sub']}">
							{if $model['is_sub'] == 1}
							<input type="hidden" name="data[mch_id]" value="{$model['mch_id']}">
							<div class="am-form-group"> 
							    <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">
									商户号 <span class="tpl-form-line-small-title">MCH_ID</span> 
								</label>
								<div class="am-u-sm-9 am-u-end"> 
								    <input type="text" class="tpl-form-input" value="{$model['mch_id']}" disabled>
								</div>
							</div>
							{else /}
							<div class="am-form-group"> 
							    <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">
									商户号 <span class="tpl-form-line-small-title">MCH_ID</span> 
								</label>
								<div class="am-u-sm-9 am-u-end"> 
								    <input type="text" class="tpl-form-input" name="data[mch_id]" value="{$model['mch_id']}">
								    <small>
								        我还没有，<a href="<?= url('wxapp.register/wxpay') ?>">去申请</a>
								    </small>
								</div>
							</div>
							<div class="am-form-group"> 
							    <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 
							        API密钥 <span class="tpl-form-line-small-title">APIv3</span> 
							    </label>
								<div class="am-u-sm-9 am-u-end"> 
								    <input type="text" class="tpl-form-input" name="data[api_key]" value="{$model['api_key']}"> 
								</div>
							</div>
							<div class="widget-head am-cf">
                                <div class="widget-title am-fl">API证书</div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">
                                    证书 <span class="tpl-form-line-small-title">序列号</span>
                                </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[api_serial_no]"
									value="{$model['api_serial_no']}" required>
                                </div>
                            </div>
							<div class="am-form-group am-padding-top"> 
							    <label class="am-u-sm-3 am-u-lg-2 am-form-label"> 
							        API证书 <span class="tpl-form-line-small-title">apiclient_cert.pem</span> 
							    </label>
								<div class="am-u-sm-9 am-u-end"> 
								    <textarea rows="3" name="data[cert_pem]">{$model['cert_pem']}</textarea>
									<small>
									    退款功能必填：使用文本编辑器打开apiclient_cert.pem文件，将文件的全部内容复制进来
									</small> 
								</div>
							</div>
							<div class="am-form-group"> 
							    <label class="am-u-sm-3 am-u-lg-2 am-form-label"> 
							        API证书 <span class="tpl-form-line-small-title">apiclient_key.pem</span> 
							    </label>
								<div class="am-u-sm-9 am-u-end"> 
								    <textarea rows="3" name="data[key_pem]">{$model['key_pem']}</textarea>
									<small>
									    退款功能必填：使用文本编辑器打开apiclient_key.pem文件，将文件的全部内容复制进来
									</small> 
							    </div>
							</div>
							<input type="hidden" name="data[serial_no]" value="{$model['serial_no']}">
							<input type="hidden" name="data[certificates]" value="{$model['certificates']}">
							<input type="hidden" name="data[expire_time]" value="{$model['expire_time']}">
							{if !empty($model['serial_no'])}
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">平台证书</div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">
                                    证书 <span class="tpl-form-line-small-title">序列号</span>
                                </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" value="{$model['serial_no']}" disabled>
                                </div>
                            </div>
							<div class="am-form-group am-padding-top">
								<label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">
                                    证书 <span class="tpl-form-line-small-title">报文</span>
                                </label>
								<div class="am-u-sm-9 am-u-end">
									 <textarea rows="6" disabled>{$model['certificates']}</textarea>
									<small>到期时间：{$model['expire_time']|date='Y-m-d'}，到期后会自动更新</small>
								</div>
							</div>
							{/if}
							<div class="am-form-group">
								<div class="am-u-sm-9 am-u-sm-push-2 am-margin-top-lg"> 
								    <button type="submit" class="j-submit am-btn am-btn-secondary">提交 </button> 
								</div>
							</div>
							{/if}
							{else /}
                            <div class="tips am-margin-bottom-sm am-u-sm-12">
                                <div class="pre-error">
                                    <p>未绑定授权小程序</p>
                                </div>
                            </div>
                            {/if}
						</fieldset>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<script>
	$(function() {
		new Vue({
			el: '#my-form',
			data: {
				is_sub: "{$model['is_sub']}"
			}
		});
		$('#my-form').formPost();
	});
</script>
